<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport"
        content="width=device-width,initial-scale=1.0,viewport-fit=cover,maximum-scale=1.0,minimum-scale=1.0,user-scalable=no">
    <title>尤迈桃李会</title>
    <script src="js/rem.js"></script>
    <link rel="stylesheet" href="https://g.alicdn.com/de/prismplayer/2.8.2/skins/default/aliplayer-min.css" />
    <link rel="stylesheet" href="css/weui.min.css">
    <link rel="stylesheet" href="css/jquery-weui.min.css">
    <link rel="stylesheet" href="css/public.css">
    <link rel="stylesheet" href="css/ot-signIn.css">
    <link rel="stylesheet" href="css/date.css">
    <script>(function () { var _53code = document.createElement("script"); _53code.src = "https://tb.53kf.com/code/code/96d8f960b261e49515450f8953b044bc5/1"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(_53code, s); })();</script>
</head>

<body>
    <div class="pub_bar" title="尤迈桃李会" left="back"></div>
    <!--  -->
    <div class="pub-container bgwhite">
        <img class="signIn_bg" src="./image/hxl/hxl-sign-bg.png" alt="">
        <div class="signIn plr15">
            <div class="signIn_cont">
                <div class="signIn_top plr15">
                    <div class="signIn_p1">已连续签到<span></span>天 <img src="./image/i-signin.png" alt=""></div>
                    <div class="signIn_p2">坚持签到，赢心动好礼</div>
                </div>
                <!-- active active2 -->
                <div class="date">
                    <img class="prev" src="./image/hxl/hxl-sign-left.png" alt="">
                    <img class="next" src="./image/hxl/hxl-sign-right.png" alt="">
                    <div id='date' class="plr15"></div>
                </div>
                <!--  -->
                <div class="plr15">
                    <a href="./user-share-i.html">
                        <div class="signIn_btn">签到成功，邀请好友一起来</div>
                    </a>
                </div>
                <!--  -->
                <div class="signIn_p3">去积分商城查看可兑换的礼品</div>
            </div>
        </div>
    </div>
    <script src="https://g.alicdn.com/de/prismplayer/2.9.3/aliplayer-h5-min.js"></script>
    <script src="js/jquery-3.6.0.min.js"></script>
    <script src="js/jquery-weui.min.js"></script>
    <script src="js/md5.js"></script>
    <script src="js/public.js"></script>
    <script src="js/date.js"></script>
    <script>
        let nowY = new Date().getFullYear()
        let nowM = new Date().getMonth() + 1
        let nowD = new Date().getDate()

        var d = new DateJs({
            inputEl: '#inputdate',
            el: '#date'
        })
        console.log(d)

        function getSignIn() {
            for (let i = 0; i < $(".month-day").length; i++) {
                year = $(".month-day").eq(i).attr('data-year')
                month = $(".month-day").eq(i).attr('data-month')
                day = $(".month-day").eq(i).html()
            }
        }
        getSignIn()

        $('.prev').click(function () {
            $(".change-date").eq(1).trigger('click')
            getData()
        })
        $('.next').click(function () {
            $(".change-date").eq(2).trigger('click')
            getData()
        })

        // 获取签到信息
        function getData() {
            gethttp('/lt/attendance', {
                hasToken: true,
                data: {
                    type: 'c',
                    user: getCookie('userId'),
                },
                success: function (res) {
                    let list = res.data.list

                    $('.signIn_p1 span').html(res.data.continuousDay)

                    for (let i = 0; i < $(".month-day").length; i++) {
                        let year = $(".month-day").eq(i).attr('data-year')
                        let month = $(".month-day").eq(i).attr('data-month')
                        let day = $(".month-day").eq(i).html()
                        list.forEach(function (item, index) {
                            let y = item.createdAtUi.split('-')[0]
                            let m = item.createdAtUi.split('-')[1] < 10 ? item.createdAtUi.split('-')[1].substr(1) : item.createdAtUi.split('-')[1]
                            let d = item.createdAtUi.split('-')[2] < 10 ? item.createdAtUi.split('-')[2].substr(1) : item.createdAtUi.split('-')[2]
                            if (year = y && month == m && day == d) {
                                console.log(nowY, nowM, nowD)
                                if (nowY == y && nowM == m && nowD == d) {
                                    $(".month-day").eq(i).addClass('active')
                                } else {
                                    $(".month-day").eq(i).addClass('active2')
                                }
                            }
                        })
                    }

                }
            })
        }

        // 签到
        posthttp('/attendance', {
            hasToken: true,
            data: {
                type: 'c',
                user: getCookie('userId')
            },
            success: function (res) {
                if (res.code == '01') {
                    toast('签到成功')
                    getData()
                }
            }
        })
    </script>
</body>

</html>